/******************************************************************************
  Grog Engine sample app - v0.1 - (c)2007 Naicigam
  ------------------------------------------------
  Filename: Input.h
  Creation date: 03/09/2007
  Author: Juan Manuel Alvarez
 ******************************************************************************/

//------------------------------------------------------------------------------
#ifndef INPUT_H
#define INPUT_H
//------------------------------------------------------------------------------

#include "system/System.h"
//------------------------------------------------------------------------------
namespace leo
{
//------------------------------------------------------------------------------
class LEO_API Input
{
	//////////////////////////////////////////////////////
	// TO-DO: Input has to be a singleton!!!!
	//////////////////////////////////////////////////////

protected:

	// keyboard buffers
	unsigned char KeyBuffer[256];
	unsigned char KeyPrevBuffer[256];
	unsigned char KeyEvent[256];

	// mouse position
	long MouseScreenAbsPos[3];
	long MouseRelPos[3];

	// mouse buttons
	unsigned char MouseBut[3];
	bool MouseButClick[3];
	bool ButState[3];

	// update
	void UpdateMouse();
	void UpdateKeyboard();

	// constructor
	Input();

public:

	enum
	{
		POS_X,
		POS_Y,
		POS_Z
	};

	enum MouseButton
	{
		MB_1,
		MB_2,
		MB_3
	};

	enum KeyState
	{
		KS_NONE,
		KS_DOWN,
		KS_UP
	};

	// destructor
	virtual ~Input();

	virtual bool Init() = 0;
	virtual void Update() = 0;
	virtual void Deinit() = 0;
    
	// devices acquisition
	virtual void Acquire() = 0;
	virtual void Reacquire() = 0;
	virtual void Unacquire() = 0;

	void SetMousePos(long x, long y, long z);
	void EventClean();
	virtual void Reset();

	// accessors
	inline bool GetKeyDown(unsigned int uiKeyID);
	inline bool GetKeyEventDown(unsigned int uiKeyID);
	inline bool GetKeyEventUp(unsigned int uiKeyID);

	inline bool GetMouseBut(unsigned int uiButID);
	inline bool GetMouseClick(unsigned int uiButID);
	inline long GetMouseScrAbsPos(unsigned int uiButID);
	inline long GetMouseRelPos(unsigned int uiButID);
};
//------------------------------------------------------------------------------
#include "Input.inl"
//------------------------------------------------------------------------------
} // end namespace
//------------------------------------------------------------------------------
#endif //INPUT_H
//------------------------------------------------------------------------------